<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# OPTIONS_GHC -fno-warn-name-shadowing #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP, DeriveDataTypeable #-}</span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &gt;= 701
</span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-8"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Module      :  Control.Concurrent.STM.TChan</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2004</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Portability :  non-portable (requires STM)</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- TChan: Transactional channels</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- (GHC only)</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Control.Concurrent.STM.TChan</span><span> </span><span class="hs-special">(</span><span class="hs-cpp">
#ifdef __GLASGOW_HASKELL__
</span><span>        </span><span class="annot"><span class="hs-comment">-- * TChans</span></span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier">TChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Construction</span></span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#newTChan"><span class="hs-identifier">newTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#newTChanIO"><span class="hs-identifier">newTChanIO</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#newBroadcastTChan"><span class="hs-identifier">newBroadcastTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#newBroadcastTChanIO"><span class="hs-identifier">newBroadcastTChanIO</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#dupTChan"><span class="hs-identifier">dupTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#cloneTChan"><span class="hs-identifier">cloneTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Reading and writing</span></span><span>
</span><span id="line-37"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#readTChan"><span class="hs-identifier">readTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#tryReadTChan"><span class="hs-identifier">tryReadTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#peekTChan"><span class="hs-identifier">peekTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#tryPeekTChan"><span class="hs-identifier">tryPeekTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#writeTChan"><span class="hs-identifier">writeTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#unGetTChan"><span class="hs-identifier">unGetTChan</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>        </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#isEmptyTChan"><span class="hs-identifier">isEmptyTChan</span></a></span><span class="hs-cpp">
#endif
</span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#ifdef __GLASGOW_HASKELL__
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.html#"><span class="hs-identifier">GHC.Conc</span></a></span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.html#"><span class="hs-identifier">Data.Typeable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier">Typeable</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#define _UPK_(x) {-# UNPACK #-} !(x)
</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- | 'TChan' is an abstract type representing an unbounded FIFO channel.</span><span>
</span><span id="line-55"></span><span class="hs-keyword">data</span><span> </span><span id="TChan"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-var">TChan</span></a></span></span><span> </span><span id="local-6989586621679037093"><span class="annot"><a href="#local-6989586621679037093"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="TChan"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-var">TChan</span></a></span></span><span> </span><span class="hs-identifier">_UPK_</span><span class="hs-special">(</span><span class="hs-identifier">TVar</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">TVarList</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-56"></span><span>                     </span><span class="hs-identifier">_UPK_</span><span class="hs-special">(</span><span class="hs-identifier">TVar</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">TVarList</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-57"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679037036"><span id="local-6989586621679037041"><span class="annot"><span class="annottext">TChan a -&gt; TChan a -&gt; Bool
(TChan a -&gt; TChan a -&gt; Bool)
-&gt; (TChan a -&gt; TChan a -&gt; Bool) -&gt; Eq (TChan a)
forall a. TChan a -&gt; TChan a -&gt; Bool
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: TChan a -&gt; TChan a -&gt; Bool
$c/= :: forall a. TChan a -&gt; TChan a -&gt; Bool
== :: TChan a -&gt; TChan a -&gt; Bool
$c== :: forall a. TChan a -&gt; TChan a -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-58"></span><span>
</span><span id="line-59"></span><span class="hs-keyword">type</span><span> </span><span id="TVarList"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TVarList"><span class="hs-identifier hs-var">TVarList</span></a></span></span><span> </span><span id="local-6989586621679037034"><span class="annot"><a href="#local-6989586621679037034"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TList"><span class="hs-identifier hs-type">TList</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037034"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span class="hs-keyword">data</span><span> </span><span id="TList"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TList"><span class="hs-identifier hs-var">TList</span></a></span></span><span> </span><span id="local-6989586621679037087"><span class="annot"><a href="#local-6989586621679037087"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="TNil"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="TCons"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TCons"><span class="hs-identifier hs-var">TCons</span></a></span></span><span> </span><span class="annot"><a href="#local-6989586621679037087"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-identifier">_UPK_</span><span class="hs-special">(</span><span class="hs-identifier">TVarList</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="hs-comment">-- |Build and return a new instance of 'TChan'</span><span>
</span><span id="line-63"></span><span id="local-6989586621679037092"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#newTChan"><span class="hs-identifier hs-type">newTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037092"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-64"></span><span id="newTChan"><span class="annot"><span class="annottext">newTChan :: forall a. STM (TChan a)
</span><a href="Control.Concurrent.STM.TChan.html#newTChan"><span class="hs-identifier hs-var hs-var">newTChan</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-65"></span><span>  </span><span id="local-6989586621679037026"><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679037026"><span class="hs-identifier hs-var">hole</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TList a -&gt; STM (TVar (TList a))
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TList a
forall a. TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span>
</span><span id="line-66"></span><span>  </span><span id="local-6989586621679037024"><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037024"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TList a) -&gt; STM (TVar (TVar (TList a)))
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679037026"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-67"></span><span>  </span><span id="local-6989586621679037023"><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037023"><span class="hs-identifier hs-var">write</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TList a) -&gt; STM (TVar (TVar (TList a)))
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679037026"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-68"></span><span>  </span><span class="annot"><span class="annottext">TChan a -&gt; STM (TChan a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TVar (TVar (TList a)) -&gt; TVar (TVar (TList a)) -&gt; TChan a
forall a. TVar (TVarList a) -&gt; TVar (TVarList a) -&gt; TChan a
</span><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-var">TChan</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037024"><span class="hs-identifier hs-var">read</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037023"><span class="hs-identifier hs-var">write</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span>
</span><span id="line-70"></span><span class="hs-comment">-- |@IO@ version of 'newTChan'.  This is useful for creating top-level</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- 'TChan's using 'System.IO.Unsafe.unsafePerformIO', because using</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- 'atomically' inside 'System.IO.Unsafe.unsafePerformIO' isn't</span><span>
</span><span id="line-73"></span><span class="hs-comment">-- possible.</span><span>
</span><span id="line-74"></span><span id="local-6989586621679037084"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#newTChanIO"><span class="hs-identifier hs-type">newTChanIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037084"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-75"></span><span id="newTChanIO"><span class="annot"><span class="annottext">newTChanIO :: forall a. IO (TChan a)
</span><a href="Control.Concurrent.STM.TChan.html#newTChanIO"><span class="hs-identifier hs-var hs-var">newTChanIO</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-76"></span><span>  </span><span id="local-6989586621679037017"><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679037017"><span class="hs-identifier hs-var">hole</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TList a -&gt; IO (TVar (TList a))
forall a. a -&gt; IO (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVarIO"><span class="hs-identifier hs-var">newTVarIO</span></a></span><span> </span><span class="annot"><span class="annottext">TList a
forall a. TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span>
</span><span id="line-77"></span><span>  </span><span id="local-6989586621679037015"><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037015"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TList a) -&gt; IO (TVar (TVar (TList a)))
forall a. a -&gt; IO (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVarIO"><span class="hs-identifier hs-var">newTVarIO</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679037017"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-78"></span><span>  </span><span id="local-6989586621679037014"><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037014"><span class="hs-identifier hs-var">write</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TList a) -&gt; IO (TVar (TVar (TList a)))
forall a. a -&gt; IO (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVarIO"><span class="hs-identifier hs-var">newTVarIO</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679037017"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-79"></span><span>  </span><span class="annot"><span class="annottext">TChan a -&gt; IO (TChan a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TVar (TVar (TList a)) -&gt; TVar (TVar (TList a)) -&gt; TChan a
forall a. TVar (TVarList a) -&gt; TVar (TVarList a) -&gt; TChan a
</span><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-var">TChan</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037015"><span class="hs-identifier hs-var">read</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037014"><span class="hs-identifier hs-var">write</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="hs-comment">-- | Create a write-only 'TChan'.  More precisely, 'readTChan' will 'retry'</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- even after items have been written to the channel.  The only way to read</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- a broadcast channel is to duplicate it with 'dupTChan'.</span><span>
</span><span id="line-84"></span><span class="hs-comment">--</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- Consider a server that broadcasts messages to clients:</span><span>
</span><span id="line-86"></span><span class="hs-comment">--</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- &gt;serve :: TChan Message -&gt; Client -&gt; IO loop</span><span>
</span><span id="line-88"></span><span class="hs-comment">-- &gt;serve broadcastChan client = do</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- &gt;    myChan &lt;- dupTChan broadcastChan</span><span>
</span><span id="line-90"></span><span class="hs-comment">-- &gt;    forever $ do</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- &gt;        message &lt;- readTChan myChan</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- &gt;        send client message</span><span>
</span><span id="line-93"></span><span class="hs-comment">--</span><span>
</span><span id="line-94"></span><span class="hs-comment">-- The problem with using 'newTChan' to create the broadcast channel is that if</span><span>
</span><span id="line-95"></span><span class="hs-comment">-- it is only written to and never read, items will pile up in memory.  By</span><span>
</span><span id="line-96"></span><span class="hs-comment">-- using 'newBroadcastTChan' to create the broadcast channel, items can be</span><span>
</span><span id="line-97"></span><span class="hs-comment">-- garbage collected after clients have seen them.</span><span>
</span><span id="line-98"></span><span class="hs-comment">--</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- @since 2.4</span><span>
</span><span id="line-100"></span><span id="local-6989586621679037013"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#newBroadcastTChan"><span class="hs-identifier hs-type">newBroadcastTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037013"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-101"></span><span id="newBroadcastTChan"><span class="annot"><span class="annottext">newBroadcastTChan :: forall a. STM (TChan a)
</span><a href="Control.Concurrent.STM.TChan.html#newBroadcastTChan"><span class="hs-identifier hs-var hs-var">newBroadcastTChan</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-102"></span><span>    </span><span id="local-6989586621679037006"><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679037006"><span class="hs-identifier hs-var">write_hole</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TList a -&gt; STM (TVar (TList a))
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TList a
forall a. TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span>
</span><span id="line-103"></span><span>    </span><span id="local-6989586621679037005"><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037005"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TList a) -&gt; STM (TVar (TVar (TList a)))
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -&gt; TVar (TList a)
forall a. HasCallStack =&gt; [Char] -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;reading from a TChan created by newBroadcastTChan; use dupTChan first&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span>    </span><span id="local-6989586621679037003"><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037003"><span class="hs-identifier hs-var">write</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TList a) -&gt; STM (TVar (TVar (TList a)))
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679037006"><span class="hs-identifier hs-var">write_hole</span></a></span><span>
</span><span id="line-105"></span><span>    </span><span class="annot"><span class="annottext">TChan a -&gt; STM (TChan a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TVar (TVar (TList a)) -&gt; TVar (TVar (TList a)) -&gt; TChan a
forall a. TVar (TVarList a) -&gt; TVar (TVarList a) -&gt; TChan a
</span><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-var">TChan</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037005"><span class="hs-identifier hs-var">read</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679037003"><span class="hs-identifier hs-var">write</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span>
</span><span id="line-107"></span><span class="hs-comment">-- | @IO@ version of 'newBroadcastTChan'.</span><span>
</span><span id="line-108"></span><span class="hs-comment">--</span><span>
</span><span id="line-109"></span><span class="hs-comment">-- @since 2.4</span><span>
</span><span id="line-110"></span><span id="local-6989586621679037002"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#newBroadcastTChanIO"><span class="hs-identifier hs-type">newBroadcastTChanIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037002"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-111"></span><span id="newBroadcastTChanIO"><span class="annot"><span class="annottext">newBroadcastTChanIO :: forall a. IO (TChan a)
</span><a href="Control.Concurrent.STM.TChan.html#newBroadcastTChanIO"><span class="hs-identifier hs-var hs-var">newBroadcastTChanIO</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-112"></span><span>    </span><span id="local-6989586621679036995"><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679036995"><span class="hs-identifier hs-var">write_hole</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TList a -&gt; IO (TVar (TList a))
forall a. a -&gt; IO (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVarIO"><span class="hs-identifier hs-var">newTVarIO</span></a></span><span> </span><span class="annot"><span class="annottext">TList a
forall a. TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span>
</span><span id="line-113"></span><span>    </span><span id="local-6989586621679036994"><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679036994"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TList a) -&gt; IO (TVar (TVar (TList a)))
forall a. a -&gt; IO (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVarIO"><span class="hs-identifier hs-var">newTVarIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -&gt; TVar (TList a)
forall a. HasCallStack =&gt; [Char] -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;reading from a TChan created by newBroadcastTChanIO; use dupTChan first&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-114"></span><span>    </span><span id="local-6989586621679036993"><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679036993"><span class="hs-identifier hs-var">write</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TList a) -&gt; IO (TVar (TVar (TList a)))
forall a. a -&gt; IO (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVarIO"><span class="hs-identifier hs-var">newTVarIO</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TList a)
</span><a href="#local-6989586621679036995"><span class="hs-identifier hs-var">write_hole</span></a></span><span>
</span><span id="line-115"></span><span>    </span><span class="annot"><span class="annottext">TChan a -&gt; IO (TChan a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TVar (TVar (TList a)) -&gt; TVar (TVar (TList a)) -&gt; TChan a
forall a. TVar (TVarList a) -&gt; TVar (TVarList a) -&gt; TChan a
</span><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-var">TChan</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679036994"><span class="hs-identifier hs-var">read</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVar (TList a))
</span><a href="#local-6989586621679036993"><span class="hs-identifier hs-var">write</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-116"></span><span>
</span><span id="line-117"></span><span class="hs-comment">-- |Write a value to a 'TChan'.</span><span>
</span><span id="line-118"></span><span id="local-6989586621679037076"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#writeTChan"><span class="hs-identifier hs-type">writeTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037076"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679037076"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-119"></span><span id="writeTChan"><span class="annot"><span class="annottext">writeTChan :: forall a. TChan a -&gt; a -&gt; STM ()
</span><a href="Control.Concurrent.STM.TChan.html#writeTChan"><span class="hs-identifier hs-var hs-var">writeTChan</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span id="local-6989586621679036989"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036989"><span class="hs-identifier hs-var">_read</span></a></span></span><span> </span><span id="local-6989586621679036988"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036988"><span class="hs-identifier hs-var">write</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679036987"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036987"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-120"></span><span>  </span><span id="local-6989586621679036986"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036986"><span class="hs-identifier hs-var">listend</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; STM (TVarList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036988"><span class="hs-identifier hs-var">write</span></a></span><span> </span><span class="hs-comment">-- listend == TVar pointing to TNil</span><span>
</span><span id="line-121"></span><span>  </span><span id="local-6989586621679036984"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036984"><span class="hs-identifier hs-var">new_listend</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TList a -&gt; STM (TVarList a)
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TList a
forall a. TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span>
</span><span id="line-122"></span><span>  </span><span class="annot"><span class="annottext">TVarList a -&gt; TList a -&gt; STM ()
forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier hs-var">writeTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036986"><span class="hs-identifier hs-var">listend</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; TVarList a -&gt; TList a
forall a. a -&gt; TVarList a -&gt; TList a
</span><a href="Control.Concurrent.STM.TChan.html#TCons"><span class="hs-identifier hs-var">TCons</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036987"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036984"><span class="hs-identifier hs-var">new_listend</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span>  </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; TVarList a -&gt; STM ()
forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier hs-var">writeTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036988"><span class="hs-identifier hs-var">write</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036984"><span class="hs-identifier hs-var">new_listend</span></a></span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span class="hs-comment">-- |Read the next value from the 'TChan'.</span><span>
</span><span id="line-126"></span><span id="local-6989586621679037072"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#readTChan"><span class="hs-identifier hs-type">readTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037072"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037072"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-127"></span><span id="readTChan"><span class="annot"><span class="annottext">readTChan :: forall a. TChan a -&gt; STM a
</span><a href="Control.Concurrent.STM.TChan.html#readTChan"><span class="hs-identifier hs-var hs-var">readTChan</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span id="local-6989586621679036978"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036978"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span id="local-6989586621679036977"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036977"><span class="hs-identifier hs-var">_write</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-128"></span><span>  </span><span id="local-6989586621679036976"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036976"><span class="hs-identifier hs-var">listhead</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; STM (TVarList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036978"><span class="hs-identifier hs-var">read</span></a></span><span>
</span><span id="line-129"></span><span>  </span><span id="local-6989586621679036975"><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036975"><span class="hs-identifier hs-var">head</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVarList a -&gt; STM (TList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036976"><span class="hs-identifier hs-var">listhead</span></a></span><span>
</span><span id="line-130"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036975"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-131"></span><span>    </span><span class="annot"><span class="annottext">TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">STM a
forall a. STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#retry"><span class="hs-identifier hs-var">retry</span></a></span><span>
</span><span id="line-132"></span><span>    </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TCons"><span class="hs-identifier hs-type">TCons</span></a></span><span> </span><span id="local-6989586621679036973"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036973"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679036972"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036972"><span class="hs-identifier hs-var">tail</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-133"></span><span>        </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; TVarList a -&gt; STM ()
forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier hs-var">writeTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036978"><span class="hs-identifier hs-var">read</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036972"><span class="hs-identifier hs-var">tail</span></a></span><span>
</span><span id="line-134"></span><span>        </span><span class="annot"><span class="annottext">a -&gt; STM a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036973"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-135"></span><span>
</span><span id="line-136"></span><span class="hs-comment">-- | A version of 'readTChan' which does not retry. Instead it</span><span>
</span><span id="line-137"></span><span class="hs-comment">-- returns @Nothing@ if no value is available.</span><span>
</span><span id="line-138"></span><span class="hs-comment">--</span><span>
</span><span id="line-139"></span><span class="hs-comment">-- @since 2.3</span><span>
</span><span id="line-140"></span><span id="local-6989586621679037069"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#tryReadTChan"><span class="hs-identifier hs-type">tryReadTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037069"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037069"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-141"></span><span id="tryReadTChan"><span class="annot"><span class="annottext">tryReadTChan :: forall a. TChan a -&gt; STM (Maybe a)
</span><a href="Control.Concurrent.STM.TChan.html#tryReadTChan"><span class="hs-identifier hs-var hs-var">tryReadTChan</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span id="local-6989586621679036966"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036966"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span id="local-6989586621679036965"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036965"><span class="hs-identifier hs-var">_write</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-142"></span><span>  </span><span id="local-6989586621679036964"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036964"><span class="hs-identifier hs-var">listhead</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; STM (TVarList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036966"><span class="hs-identifier hs-var">read</span></a></span><span>
</span><span id="line-143"></span><span>  </span><span id="local-6989586621679036963"><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036963"><span class="hs-identifier hs-var">head</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVarList a -&gt; STM (TList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036964"><span class="hs-identifier hs-var">listhead</span></a></span><span>
</span><span id="line-144"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036963"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-145"></span><span>    </span><span class="annot"><span class="annottext">TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; STM (Maybe a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-146"></span><span>    </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TCons"><span class="hs-identifier hs-type">TCons</span></a></span><span> </span><span id="local-6989586621679036962"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036962"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679036961"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036961"><span class="hs-identifier hs-var">tl</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-147"></span><span>      </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; TVarList a -&gt; STM ()
forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier hs-var">writeTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036966"><span class="hs-identifier hs-var">read</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036961"><span class="hs-identifier hs-var">tl</span></a></span><span>
</span><span id="line-148"></span><span>      </span><span class="annot"><span class="annottext">Maybe a -&gt; STM (Maybe a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; Maybe a
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036962"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-149"></span><span>
</span><span id="line-150"></span><span class="hs-comment">-- | Get the next value from the @TChan@ without removing it,</span><span>
</span><span id="line-151"></span><span class="hs-comment">-- retrying if the channel is empty.</span><span>
</span><span id="line-152"></span><span class="hs-comment">--</span><span>
</span><span id="line-153"></span><span class="hs-comment">-- @since 2.3</span><span>
</span><span id="line-154"></span><span id="local-6989586621679036960"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#peekTChan"><span class="hs-identifier hs-type">peekTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679036960"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679036960"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-155"></span><span id="peekTChan"><span class="annot"><span class="annottext">peekTChan :: forall a. TChan a -&gt; STM a
</span><a href="Control.Concurrent.STM.TChan.html#peekTChan"><span class="hs-identifier hs-var hs-var">peekTChan</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span id="local-6989586621679036956"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036956"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span id="local-6989586621679036955"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036955"><span class="hs-identifier hs-var">_write</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-156"></span><span>  </span><span id="local-6989586621679036954"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036954"><span class="hs-identifier hs-var">listhead</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; STM (TVarList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036956"><span class="hs-identifier hs-var">read</span></a></span><span>
</span><span id="line-157"></span><span>  </span><span id="local-6989586621679036953"><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036953"><span class="hs-identifier hs-var">head</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVarList a -&gt; STM (TList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036954"><span class="hs-identifier hs-var">listhead</span></a></span><span>
</span><span id="line-158"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036953"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-159"></span><span>    </span><span class="annot"><span class="annottext">TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">STM a
forall a. STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#retry"><span class="hs-identifier hs-var">retry</span></a></span><span>
</span><span id="line-160"></span><span>    </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TCons"><span class="hs-identifier hs-type">TCons</span></a></span><span> </span><span id="local-6989586621679036952"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036952"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a -&gt; STM a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036952"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-161"></span><span>
</span><span id="line-162"></span><span class="hs-comment">-- | A version of 'peekTChan' which does not retry. Instead it</span><span>
</span><span id="line-163"></span><span class="hs-comment">-- returns @Nothing@ if no value is available.</span><span>
</span><span id="line-164"></span><span class="hs-comment">--</span><span>
</span><span id="line-165"></span><span class="hs-comment">-- @since 2.3</span><span>
</span><span id="line-166"></span><span id="local-6989586621679036951"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#tryPeekTChan"><span class="hs-identifier hs-type">tryPeekTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679036951"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679036951"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-167"></span><span id="tryPeekTChan"><span class="annot"><span class="annottext">tryPeekTChan :: forall a. TChan a -&gt; STM (Maybe a)
</span><a href="Control.Concurrent.STM.TChan.html#tryPeekTChan"><span class="hs-identifier hs-var hs-var">tryPeekTChan</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span id="local-6989586621679036946"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036946"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span id="local-6989586621679036945"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036945"><span class="hs-identifier hs-var">_write</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-168"></span><span>  </span><span id="local-6989586621679036944"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036944"><span class="hs-identifier hs-var">listhead</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; STM (TVarList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036946"><span class="hs-identifier hs-var">read</span></a></span><span>
</span><span id="line-169"></span><span>  </span><span id="local-6989586621679036943"><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036943"><span class="hs-identifier hs-var">head</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVarList a -&gt; STM (TList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036944"><span class="hs-identifier hs-var">listhead</span></a></span><span>
</span><span id="line-170"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036943"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-171"></span><span>    </span><span class="annot"><span class="annottext">TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; STM (Maybe a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-172"></span><span>    </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TCons"><span class="hs-identifier hs-type">TCons</span></a></span><span> </span><span id="local-6989586621679036942"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036942"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; STM (Maybe a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; Maybe a
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036942"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-173"></span><span>
</span><span id="line-174"></span><span class="hs-comment">-- |Duplicate a 'TChan': the duplicate channel begins empty, but data written to</span><span>
</span><span id="line-175"></span><span class="hs-comment">-- either channel from then on will be available from both.  Hence this creates</span><span>
</span><span id="line-176"></span><span class="hs-comment">-- a kind of broadcast channel, where data written by anyone is seen by</span><span>
</span><span id="line-177"></span><span class="hs-comment">-- everyone else.</span><span>
</span><span id="line-178"></span><span id="local-6989586621679037064"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#dupTChan"><span class="hs-identifier hs-type">dupTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037064"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037064"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-179"></span><span id="dupTChan"><span class="annot"><span class="annottext">dupTChan :: forall a. TChan a -&gt; STM (TChan a)
</span><a href="Control.Concurrent.STM.TChan.html#dupTChan"><span class="hs-identifier hs-var hs-var">dupTChan</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span id="local-6989586621679036938"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036938"><span class="hs-identifier hs-var">_read</span></a></span></span><span> </span><span id="local-6989586621679036937"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036937"><span class="hs-identifier hs-var">write</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-180"></span><span>  </span><span id="local-6989586621679036936"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036936"><span class="hs-identifier hs-var">hole</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; STM (TVarList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036937"><span class="hs-identifier hs-var">write</span></a></span><span>
</span><span id="line-181"></span><span>  </span><span id="local-6989586621679036935"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036935"><span class="hs-identifier hs-var">new_read</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVarList a -&gt; STM (TVar (TVarList a))
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036936"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-182"></span><span>  </span><span class="annot"><span class="annottext">TChan a -&gt; STM (TChan a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; TVar (TVarList a) -&gt; TChan a
forall a. TVar (TVarList a) -&gt; TVar (TVarList a) -&gt; TChan a
</span><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-var">TChan</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036935"><span class="hs-identifier hs-var">new_read</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036937"><span class="hs-identifier hs-var">write</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-183"></span><span>
</span><span id="line-184"></span><span class="hs-comment">-- |Put a data item back onto a channel, where it will be the next item read.</span><span>
</span><span id="line-185"></span><span id="local-6989586621679036934"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#unGetTChan"><span class="hs-identifier hs-type">unGetTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679036934"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679036934"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-186"></span><span id="unGetTChan"><span class="annot"><span class="annottext">unGetTChan :: forall a. TChan a -&gt; a -&gt; STM ()
</span><a href="Control.Concurrent.STM.TChan.html#unGetTChan"><span class="hs-identifier hs-var hs-var">unGetTChan</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span id="local-6989586621679036931"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036931"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span id="local-6989586621679036930"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036930"><span class="hs-identifier hs-var">_write</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679036929"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036929"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-187"></span><span>   </span><span id="local-6989586621679036928"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036928"><span class="hs-identifier hs-var">listhead</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; STM (TVarList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036931"><span class="hs-identifier hs-var">read</span></a></span><span>
</span><span id="line-188"></span><span>   </span><span id="local-6989586621679036927"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036927"><span class="hs-identifier hs-var">newhead</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TList a -&gt; STM (TVarList a)
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; TVarList a -&gt; TList a
forall a. a -&gt; TVarList a -&gt; TList a
</span><a href="Control.Concurrent.STM.TChan.html#TCons"><span class="hs-identifier hs-var">TCons</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679036929"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036928"><span class="hs-identifier hs-var">listhead</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-189"></span><span>   </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; TVarList a -&gt; STM ()
forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier hs-var">writeTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036931"><span class="hs-identifier hs-var">read</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036927"><span class="hs-identifier hs-var">newhead</span></a></span><span>
</span><span id="line-190"></span><span>
</span><span id="line-191"></span><span class="hs-comment">-- |Returns 'True' if the supplied 'TChan' is empty.</span><span>
</span><span id="line-192"></span><span id="local-6989586621679037061"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#isEmptyTChan"><span class="hs-identifier hs-type">isEmptyTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037061"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-193"></span><span id="isEmptyTChan"><span class="annot"><span class="annottext">isEmptyTChan :: forall a. TChan a -&gt; STM Bool
</span><a href="Control.Concurrent.STM.TChan.html#isEmptyTChan"><span class="hs-identifier hs-var hs-var">isEmptyTChan</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span id="local-6989586621679036922"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036922"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span id="local-6989586621679036921"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036921"><span class="hs-identifier hs-var">_write</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-194"></span><span>  </span><span id="local-6989586621679036920"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036920"><span class="hs-identifier hs-var">listhead</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; STM (TVarList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036922"><span class="hs-identifier hs-var">read</span></a></span><span>
</span><span id="line-195"></span><span>  </span><span id="local-6989586621679036919"><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036919"><span class="hs-identifier hs-var">head</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVarList a -&gt; STM (TList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036920"><span class="hs-identifier hs-var">listhead</span></a></span><span>
</span><span id="line-196"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TList a
</span><a href="#local-6989586621679036919"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-197"></span><span>    </span><span class="annot"><span class="annottext">TList a
</span><a href="Control.Concurrent.STM.TChan.html#TNil"><span class="hs-identifier hs-var">TNil</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; STM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-198"></span><span>    </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TCons"><span class="hs-identifier hs-type">TCons</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; STM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-199"></span><span>
</span><span id="line-200"></span><span class="hs-comment">-- |Clone a 'TChan': similar to dupTChan, but the cloned channel starts with the</span><span>
</span><span id="line-201"></span><span class="hs-comment">-- same content available as the original channel.</span><span>
</span><span id="line-202"></span><span class="hs-comment">--</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- @since 2.4</span><span>
</span><span id="line-204"></span><span id="local-6989586621679036918"><span class="annot"><a href="Control.Concurrent.STM.TChan.html#cloneTChan"><span class="hs-identifier hs-type">cloneTChan</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679036918"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679036918"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-205"></span><span id="cloneTChan"><span class="annot"><span class="annottext">cloneTChan :: forall a. TChan a -&gt; STM (TChan a)
</span><a href="Control.Concurrent.STM.TChan.html#cloneTChan"><span class="hs-identifier hs-var hs-var">cloneTChan</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-type">TChan</span></a></span><span> </span><span id="local-6989586621679036914"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036914"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span id="local-6989586621679036913"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036913"><span class="hs-identifier hs-var">write</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-206"></span><span>  </span><span id="local-6989586621679036912"><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036912"><span class="hs-identifier hs-var">readpos</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; STM (TVarList a)
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036914"><span class="hs-identifier hs-var">read</span></a></span><span>
</span><span id="line-207"></span><span>  </span><span id="local-6989586621679036911"><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036911"><span class="hs-identifier hs-var">new_read</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TVarList a -&gt; STM (TVar (TVarList a))
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">TVarList a
</span><a href="#local-6989586621679036912"><span class="hs-identifier hs-var">readpos</span></a></span><span>
</span><span id="line-208"></span><span>  </span><span class="annot"><span class="annottext">TChan a -&gt; STM (TChan a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TVar (TVarList a) -&gt; TVar (TVarList a) -&gt; TChan a
forall a. TVar (TVarList a) -&gt; TVar (TVarList a) -&gt; TChan a
</span><a href="Control.Concurrent.STM.TChan.html#TChan"><span class="hs-identifier hs-var">TChan</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036911"><span class="hs-identifier hs-var">new_read</span></a></span><span> </span><span class="annot"><span class="annottext">TVar (TVarList a)
</span><a href="#local-6989586621679036913"><span class="hs-identifier hs-var">write</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span></pre></body></html>